package com.titaniume.rqbbitmq.five;

import com.rabbitmq.client.Channel;
import com.titaniume.rqbbitmq.util.RabbitMqUtils;

import java.util.Scanner;

/**
 * @program: rqbbitmq-hello
 * @description: 生产者
 * @author: titaniume
 * @create: 2021-12-22 11:48
 */
public class EmitLog {
        public  static  final  String EXCHANGE_NAME ="logs";
        public static void main(String[] args) throws  Exception {
            Channel channel = RabbitMqUtils.getChannel();
            //声明一个交换机
            channel.exchangeDeclare(EXCHANGE_NAME,"fanout");
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入消息:");
            while (scanner.hasNext()){
                String message = scanner.nextLine();
                channel.basicPublish(EXCHANGE_NAME,"",null,message.getBytes("UTF-8"));
                System.out.println("生产者发出消息：" + message);
            }

    }
}